﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Reviewer.Entities;
using System.ServiceModel;
using System.Net.Security;

namespace Reviewer.Entities.Services
{
    /// <summary>
    /// News Service Interface
    /// </summary>
    [ServiceContract(Namespace = "Reviewer.Services")]
    public interface INewsService : IDisposable
    {
        /// <summary>
        /// Gets all.
        /// </summary>
        /// <returns></returns>
        News[] GetAll();

        /// <summary>
        /// Gets the News by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        [OperationContract]
        News GetById(int id);

        /// <summary>
        /// Gets the News by news id.
        /// </summary>
        /// <param name="newsId">The news id.</param>
        /// <returns></returns>
        [OperationContract]
        News[] GetByNewsId(Guid newsId);

        /// <summary>
        /// Gets the latest News.
        /// </summary>
        /// <param name="topCount">The top count.</param>
        /// <returns><c ref="News" /></returns>
        [OperationContract]
        News[] GetLatest(int topCount);

        /// <summary>
        /// Gets the associated game formats.
        /// </summary>
        /// <param name="newsId">The news id.</param>
        /// <returns><c ref="NewsFormat" /></returns>
        [OperationContract]
        NewsFormat[] GetAssociatedGameFormats(Guid newsId);

        /// <summary>
        /// Gets the game relations.
        /// </summary>
        /// <param name="newsId">The news id.</param>
        /// <returns></returns>
        [OperationContract]
        NewsGameRelation[] GetGameRelations(Guid newsId);

        /// <summary>
        /// Gets all by game relation.
        /// </summary>
        /// <param name="gameId">The game id.</param>
        /// <returns></returns>
        [OperationContract]
        News[] GetAllByGameRelation(Guid gameId);

        /// <summary>
        /// Searches the specified search string.
        /// </summary>
        /// <param name="searchString">The search string.</param>
        /// <returns></returns>
        [OperationContract]
        News[] Search(string value);

        /// <summary>
        /// Gets all by format.
        /// </summary>
        /// <param name="formatId">The format id.</param>
        /// <returns></returns>
        [OperationContract]
        News[] GetAllByFormat(int formatId);

        [OperationContract]
        ICollection<News> Search(Int32? newsType, Int32? format, Int32 maxResults);
    }

    /// <summary>
    /// News Administration Service Interface
    /// </summary>
    [ServiceContract(Namespace = "Reviewer.Services")]
    public interface INewsAdminService : INewsService
    {
        /// <summary>
        /// Creates the specified new news item.
        /// </summary>
        /// <param name="newsItem">The news item.</param>
        /// <returns>Created <c ref="News"/> item</returns>
        [OperationContract]
        News Save(News newsItem);

        /// <summary>
        /// Deletes the specified deleted news item.
        /// </summary>
        /// <param name="newsItem">The deleted news item.</param>
        /// <returns><c ref="True" /> if deleted otherwise <c ref="False" /></returns>
        [OperationContract]
        bool Delete(News newsItem);

        /// <summary>
        /// Deletes the News by id.
        /// </summary>
        /// <param name="id">The news id.</param>
        /// <returns><c ref="True" /> if deleted otherwise <c ref="False" /></returns>
        [OperationContract]
        bool DeleteById(int id);

        /// <summary>
        /// Deletes the by news id.
        /// </summary>
        /// <param name="newsId">The news id.</param>
        /// <returns></returns>
        bool DeleteByNewsId(Guid newsId);

        /// <summary>
        /// Sets the associated game formats.
        /// </summary>
        /// <param name="newsId">The news id.</param>
        /// <param name="formats">The formats.</param>
        [OperationContract]
        void SetAssociatedGameFormats(Guid newsId, NewsFormat[] formats);

        /// <summary>
        /// Sets the game relations.
        /// </summary>
        /// <param name="newsId">The news id.</param>
        /// <param name="gameRelations">The game relations.</param>
        [OperationContract]
        void SetGameRelations(Guid newsId, NewsGameRelation[] gameRelations);
    }
}
